package com.bnlr.lrparking.appui.home;


import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.bnlr.lrparking.R;
import com.bnlr.lrparking.appui.login.VerificaActivity;
import com.bnlr.lrparking.app.AppConfig;
import com.bnlr.lrparking.appui.publish.ChoseIdentityActivity;
import com.bnlr.lrparking.appui.publish.MyPublishActivity;
import com.bnlr.lrparking.appui.publish.PublishActivity;
import com.bnlr.lrparking.appui.publish.PublishBegActivity;
import com.bnlr.lrparking.base.BaseFragment;

import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;

/**
 * 发布
 * @author tian
 */
public class PublishFragment extends BaseFragment {

    private Unbinder unbinder;
    private  View mview;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        mview = inflater.inflate(R.layout.fragment_publish, container, false);
        unbinder = ButterKnife.bind(this,mview);
        initView();
        return mview;
    }
    @OnClick({R.id.my_publish,R.id.ll_cz,R.id.ll_cs,R.id.ll_qz,R.id.ll_qg})
    public void publishOnClick (View view) {
        if (!AppConfig.getInstance().getBoolean("isLogin",false)) {
            startActivity(new Intent(getActivity(), VerificaActivity.class));
            return;
        }
        switch (view.getId()) {
            case R.id.my_publish:
                startActivity(new Intent(getActivity(), MyPublishActivity.class));
                break;
            case R.id.ll_cz:
                startActivity(new Intent(getActivity(), PublishActivity.class).putExtra("publish_tag",1));
                break;
            case R.id.ll_cs:
                startActivity(new Intent(getActivity(), ChoseIdentityActivity.class)
                        .putExtra("from",2));
                break;
            case R.id.ll_qz:
                startActivity(3);
                break;
            case R.id.ll_qg:
                startActivity(4);
                break;
            default:
                break;
        }
    }
    private void initView() {
    }

    /**
     *
     * @param tag 1= 出租 2=出售 3=求租 4=求购
     */
    public void startActivity (int tag) {
        startActivity(new Intent(getActivity(), PublishBegActivity.class)
        .putExtra("publish_tag",tag));
    }
    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }
}
